< previous page page_301 next page >

Page 301
EXERCISE
Write Code to Move Through the Recordset
1. Double-click each of the command buttons in turn and add the following code:
Private Sub cmdNext_Click()
With datEmployees.Recordset
If Not .EOF Then
.MoveNext
If .EOF Then
.MovePrevious
End If
End If
End With
End Sub

Private Sub cmdPrevious_Click()
With datEmployees.Recordset
If Not .BOF Then
.MovePrevious
If .BOF Then
.MoveNext
End If
End If
End With
End Sub

Private Sub cmdFirst_Click()
datEmployees.Recordset.MoveFirst
End Sub

Private Sub cmdLast_Click()
datEmployees.Recordset.MoveLast
End Sub
2. You should also update the ToggleButtons routine to turn off these command buttons when you enter an editing mode:
Private Sub ToggleButtons()
If cmdClose.Caption = "&Close" Then
cmdClose.Caption = "&Cancel"
Else
cmdClose.Caption = "&Close"

 
< previous page page_301 next page >

If you like this book, buy it!